package dhcpha.clinical.adapter;

import java.util.List;
import java.util.Map;

import org.xutils.x;
import org.xutils.view.annotation.ViewInject;

import dhcpha.clinical.activity.R;
import dhcpha.clinical.adapter.PatDiagAdapter.ViewHolder;
import dhcpha.clinical.bean.Diag;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class VersionAdapter extends BaseAdapter {

	private Context context;
	private List<Map<String, String>> versionInfo;
	public ViewHolder viewHolder;
	public Map<String, String> map;
	public VersionAdapter(Context context,List<Map<String, String>> versionInfo) {
	   this.context=context;
	   this.versionInfo=versionInfo;
	}
	@Override
	public int getCount() {
		if (null != versionInfo) {
			return versionInfo.size();
		} else {
			return 0;
		}
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		if(view == null){
			view = LayoutInflater.from(context).inflate(R.layout.item_more, null);
			viewHolder=new ViewHolder();
			x.view().inject(viewHolder,view);  
			view.setTag(viewHolder);
			}else {
		   viewHolder=(ViewHolder)view.getTag();
			}
           map = versionInfo.get(position);
          for (String key:map.keySet()) {
			viewHolder.info.setText(key);
			viewHolder.infoDesc.setText(map.get(key));
		  }
  	      return view;    
	   }
	
	class ViewHolder{
		
		@ViewInject(R.id.info)
		 public TextView info;
		@ViewInject(R.id.infoDesc)
		 public TextView infoDesc;
	}
}
